<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>制作预算成本清单</title>
<link href="/res/css/respective/priceAsk/buyer.css" rel="stylesheet">
 <link href="/res/third/city-picker/css/city-picker.css" rel="stylesheet">
	<style>
.backcontent .backfoot {
	padding-left: 0px;
}
.city-picker-span{
	display: inline-block;
}
</style>
</head>
<body>
	<div class="warp">
		[#include "/front/common/front_headAzt.html"]
		<div class="backcontent">
			<div class="back-main">
				<div class="mainContent"> 
					<div class="createOp" style="margin-top: 48px;">
						<h1>制作预算成本清单</h1>
						<form type="post" id="subform" autocomplete="off"
							data-validator-option="{theme:'yellow_right',timely:3, focusCleanup:true,stopOnError:true,focusInvalid:true}">
							<div class="juZhong">
								<div style="padding: 35px 70px;background: white;">
                                    <input type="hidden" id="choosen"/>
									<table class="table noBorder" style="width: 100%;">
										<thead>
			                            <tr class="handHead">
			                                <th style="width: 20%;">供应商</th>
			                                <th style="width: 10%;">报价数量 </th>
			                                <th style="width: 15%;">清单报价 </th> 
			                                <th style="width: 25%;">报价系统  </th>
			                                <th colspan="3" style="width: 30%;">操作</th>
			                            </tr>
			                            </thead>
			                            <tbody id = "budgetcreate">
			                            <!--默认显示8行-->
			                            [#list createList as create]
			                            <tr id="create${create.quoteid}">
			                                <td style="text-align: left;padding-left: 15px;">
												<label>
			                                    <input class="checkOffset" type="radio" name="create" onclick="calculate(${create.totalPrice},${create.quoteid})"/>
			                                    <em>${create.companyName}</em>
                                                </label>
			                                    [#--<a class="bugetTypeIcon">集</a>--]
			                                </td>
			                                <td>${create.count}</td>
			                                <td class="contentBold">￥${create.totalPrice}</td> 
			                                <td class="textoverflow"><em class="opLink" title="${create.categoryNames}">${create.categoryNames}</em></td>
			                                <td colspan="3">
			                                    <a style="display: none;">收起</a>
			                                    <a id="showdetail${create.quoteid}" href="javascript:getdetail(#{create.quoteid})">查看清单</a>
			                                    
			                                </td>
			                            </tr>
			                            <!-- 等待插入 -->
			                            [/#list]
			                            </tbody>
			                            <tfoot>
			                            <tr class="tableBorde">
			                                <td class="fenye" colspan="7"
			                                    style="text-align: right; background: #f8f8f8;padding: 20px 15px;"><em style="vertical-align: middle;">预算成本总价：</em>&nbsp;&nbsp;&nbsp;
			                                    <span id="totalPrice" class="contentBold" style="font-size: 18px;vertical-align: middle;">￥0</span>
			                                </td>
			                            </tr>
			                            
			                            </tfoot>
									</table>
									<div class="confirmForm" style="text-align: left;">
		             				<button class="backButt" type="button"  onclick="location.href='/enquiry/design/quote/detail/${enqid}';"  style="padding: 0 10px;">返回报价列表</button>
					                <button class="backButt" style="float: right;padding: 0 10px;width: auto;" onclick="createbudget()" type="button" >生成预算成本清单</button>
		        				</div>
								</div>  
							</div> 
						</form> 
					</div>
				</div>
			</div>
			<!-- 底部菜单-->
			[#include "/front/common/front_footerAzt.html"]
		</div>

	</div>
	<script src="/res/js/common/jquery.1.9.1.min.js"></script>
	<script src="/res/js/buyer/buyer.js"></script>
	<script src="/res/js/common/common.js"></script>
	<script src="/res/third/layer/layer.js"></script>
<script src="/res/third/layer/layer.extends.js"></script>
<script type="text/javascript">

	function getdetail(quoteid){
		if($("#detail"+quoteid).length>0){
			if($("#detail"+quoteid).is(":hidden")){
				$("#detail"+quoteid).show();
				$(".detail"+quoteid).show();
				$("#showdetail"+quoteid).text("收起");
			} else {
				$("#detail"+quoteid).hide();
				$(".detail"+quoteid).hide();
				$("#showdetail"+quoteid).text("查看详情");
			}
			return;
		}
		$.ajax({
			type : "post",
			dataType : "text",
			url : "/enquiry/budget/design/create/quote/"+quoteid,
			data : "",
			success : function(data) {//成功的时候调用
				$("#create"+quoteid).after(data); 
				$("#showdetail"+quoteid).text("收起");
			}
		});
	}
	function calculate(price,id){
		$("#totalPrice").text("￥"+price);
		$("#choosen").val(id);
	}
	
	function createbudget(){
		if(!$("#choosen").val()){
			layer.msgShort("至少选择一行清单!");
			return false;
		}

        layer.post({
            url : "/enquiry/budget/design/create/save",
            data : {
                quoteid : $("#choosen").val()
            },
            success : function(data) {//成功的时候调用
				if(data.success){
                    layer.alert("制作预算成本清单成功",function () {
                        location.href="/enquiry/budget/detail/"+data.obj+"/t/1";
                    });
				}else{
                    layer.msgShort(data.msg);
				}
                //待完善
            }
        },"");
	}
</script>
</body>
</html>
